import { reactive, toRefs, onMounted } from "vue"
import { userInfo } from "@/apis/user"
interface userInfoTYpe {
    nickName: string,
    loginName: string,
    introduceSign: string
}
interface stateType {
    loading: boolean,
    user: userInfoTYpe
}

export default function userInfoHook() {
    const state: stateType = reactive({
        loading: false,
        user: {
            nickName: '',
            loginName: '',
            introduceSign: ''
        }
    })

    onMounted(async () => {
        state.loading=true
        let res = await userInfo()
        state.loading=false
        state.user=res.data

    })

    return {
        ...toRefs(state)
    }
}
